# -*- coding: utf-8 -*-
'''
@author: Hugo
@file: css偏移.py
@time: 2021/8/31 18:52
'''
html = '''
<span class="prc_wp" style="width:48px">
<em class="rel">
<b style="width:48px;left:-48px">
<i title="550" style="width: 16px;">4</i>
<i title="550" style="width: 16px;">2</i>
<i title="550" style="width: 16px;">8</i></b>
<b title="550" style="width: 16px;left:-48px">5</b>
<b title="550" style="width: 16px;left:-16px">0</b>
<b title="550" style="width: 16px;left:-32px">5</b>
</em></span>

'''
import re
from lxml import etree

h = etree.HTML(html)
tag = h.xpath('//em[@class="rel"]/b')
for i in tag[1:]:
    pass
s = [(i.text, i.xpath('@style')[0]) for i in tag[1:]]
xl = ['4','2','8']
for a ,b in s:
    print(a)
    print(b)
    left = re.search('width: 16px;left:-(\d+)px',b).group(1)
    print(left)
    xl [-int(left) // 16] = a
    print(xl)












